package at.kaok.gui.panels;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import at.kaok.betfair.Global;
import at.kaok.gui.BetFrame;
import at.kaok.gui.Start;

public class LoginPanel extends JPanel {
	JTextField fUser;
	JPasswordField fPwd;
	JButton btnLogin;
	
	public LoginPanel() {
		this.fUser = new JTextField("kotzinao7");
		this.fPwd = new JPasswordField("ginaSS12");
		this.btnLogin = new JButton("Login");
		this.setLayout(null);
		fUser.setBounds(30, 10, 250, 25);
		fPwd.setBounds(30, 45, 250, 25);
		btnLogin.setBounds(30, 85, 70, 25);
		this.add(fUser);
		this.add(fPwd);
		this.add(btnLogin);
		
		btnLogin.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				String session= Global.login(fUser.getText(), fPwd.getText());
				if(session!=null){
					BetFrame.start();
					BetFrame.setSession(session);
					Start.getInstance().dispose();
				}
				
			}
		});
	}
}
